<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>onmousedown 和onmouseup</title>
    <script>
        function lighton() {
            document.getElementById('myimage').src = "images/bulbon.gif";
        }
        function lightoff() {
            document.getElementById('myimage').src = "images/bulboff.gif";
        }
    </script>
</head>

<!-- 当用户按下鼠标按钮时，更换一幅图像。 -->

<body>
    <img id="myimage" onmousedown="lighton()" onmouseup="lightoff()" src="images/bulboff.gif" width="100"
        height="180" />
    <p>点击不释放鼠标灯将一直亮着!</p>
</body>

</html>